package com.cy.util;

import com.cy.entity.User;
import org.springframework.stereotype.Component;

/**
 * @Author: cy
 * @Date: 2022/01/02/17:07
 * @Description:    持有用户信息，用以代替session对象
 */
@Component
public class HostHolder {

    private final ThreadLocal<User> users = new ThreadLocal<User>();

    public void setUser(User user){
        users.set(user);
    }

    public User getUser(){
        return users.get();
    }

    public void clear(){
        users.remove();
    }


}
